<?php
/**
 * @brief 
 *
 * @license 	http://www.gnu.org/licenses/gpl-3.0.txt GNU General Public License
 * @copyright	2007 David Singer
 * @author	   	David Singer <david@ramaboo.com>
 * @version    	1.0.0
 */


require_once('../../includes/common.php');

try{
	$uptime = get_uptime();
	
	// try to contact extbind.com
	$network = 0;
	
	$ch = curl_init();
	curl_setopt($ch, CURLOPT_URL, "http://extbind.com/ping/");
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
	$output = curl_exec($ch);
	$info = curl_getinfo($ch);
	curl_close($ch);
	
	$network = $info['http_code'];
	
	$server = array(
		'name'=>'ExtBIND', 
		'appVersion'=>VERSION, 
		'phpVersion'=>PHP_VERSION, 
		'dbVersion'=>DB_VERSION, 
		'dbDriver'=>DB_DRIVER, 
		'bindVersion'=>BIND_VERSION, 
		'debug'=>DEBUG,
		'uptime'=>$uptime,
		'network'=>$network
	);
	
	$rows = array();
	$rows[] = $server;
	$json = array();
	$json['results'][0] = $server;
	$json['success'] = true;
	$json['msg'] = "Server preferences loaded.";
} catch (Exception $e) {
	$json['results'] [0] = array(); // blank array
	$json['success'] = false;
	$json['msg'] = $e->getMessage();
}

$output = json_encode($json);
header_no_cache(strlen($output), 'application/json');
echo $output;
?>